package com.easy.west.westclient.api.department.api;

import android.content.Context;
import android.support.annotation.NonNull;

import com.easy.west.westclient.api.base.callback.BaseCallBack;
import com.easy.west.westclient.api.base.impl.BaseImpl;
import com.easy.west.westclient.api.department.bean.DepartMentInfo;
import com.easy.west.westclient.api.department.bean.DepartMentList;
import com.easy.west.westclient.api.department.event.FindAllEvent;
import com.easy.west.westclient.api.department.event.FindTopDepartMent;
import com.easy.west.westclient.api.department.event.FindoneDepartMentEvent;
import com.easy.west.westclient.api.department.event.OtherClassDepartMentEvent;
import com.easy.west.westclient.api.department.event.QueryDepartMentEvent;
import com.easy.west.westclient.util.UUIDGenerator;

/**
 * 查找部门实现
 * Created by xiatao on 2018/8/15.
 */

public class DepartMentImpl extends BaseImpl<DepartMentService> implements DepartMentApi{
    public DepartMentImpl(@NonNull Context context) {
        super(context);
    }

    /**
     * 所有注释前往继承接口查看
     * @return
     */
    @Override
    public String findalldepartMent() {
        String uuid = UUIDGenerator.getUUID();
        service.findAllDepartMent().enqueue(new BaseCallBack<>(new FindAllEvent(uuid)));
        return uuid;
    }

    /**
     * 同上
     * @return
     */
    @Override
    public String findallParentDepartMent() {
        String uuid = UUIDGenerator.getUUID();
        service.findoneClassDepartMent().enqueue(new BaseCallBack<DepartMentList>(new FindTopDepartMent(uuid)));
        return uuid;
    }

    /**
     *查找部门详情
     * @param did 部门id
     * @return
     */
    @Override
    public String finddepartmentinfo(long did) {
        String uuid = UUIDGenerator.getUUID();
        service.findoneDepartMentInfo(did).enqueue(new BaseCallBack<DepartMentInfo>(new FindoneDepartMentEvent(uuid)));
        return uuid;
    }

    /**
     *查找其他级的部门
     * @param fid
     * @return
     */
    @Override
    public String findotherClassDepartMent(long fid) {
        String uuid = UUIDGenerator.getUUID();
        service.findOtherClassDepartMent(fid).enqueue(new BaseCallBack<DepartMentList>(new OtherClassDepartMentEvent(uuid)));
        return uuid;
    }

    @Override
    public String queryDepartment(String name) {
        String uuid = UUIDGenerator.getUUID();
        service.queryDepartment(name).enqueue(new BaseCallBack<DepartMentList>(new QueryDepartMentEvent(uuid)));
        return uuid;
    }


}
